package com.iuie.ns.devtools.to;

import com.iuie.ns.frame.utils.StringUtils;

public abstract class DevHeaderTO {
	
	private String className;
	
	private String packagePath;
	
	private String tableName;
	
	private String db;
	
	public String getClassName() {
		return className;
	}
	public void setClassName(String className) {
		this.className = className;
	}
	public String getPackagePath() {
		return packagePath;
	}
	public void setPackagePath(String packagePath) {
		this.packagePath = packagePath;
	}
	public String getTableName() {
		return tableName;
	}
	public void setTableName(String tableName) {
		this.tableName = tableName;
	}
	public String getDb() {
		return db;
	}
	public void setDb(String db) {
		this.db = db;
	}
	
	public String getSimpleClassName() {
		if (StringUtils.isNotBlank(this.className)) {
			return this.className.substring(0, this.className.length() - 2);
		}
		return null;
	}
	
	public String getVariableSimpleClassName() {
		String simpleClassName = getSimpleClassName();
		if (StringUtils.isNotBlank(simpleClassName)) {
			return StringUtils.lowerCase(simpleClassName.substring(0, 1)) + simpleClassName.substring(1, simpleClassName.length());
		}
		return null;
	}
	
	public String getFullPath(String type) {
		StringBuilder sb = new StringBuilder(12);
		if (StringUtils.isNotBlank(this.packagePath)) {
			sb.append(this.packagePath);
		}
		if (StringUtils.isNotBlank(type)) {
			sb.append(".")
				.append(type)
				.append(".");
		}
		if (StringUtils.isNotBlank(this.className)) {
			sb.append(getSimpleClassName());
			if (StringUtils.equals(type, "vo")) {
				sb.append("VO");
			} else if (StringUtils.equals(type, "mapper")) {
				sb.append("Mapper");
			}
		}
		return sb.toString();
	}
}
